package com.cardbaobao.cardbabyclient.ui.pop;

import android.content.Context;
import android.graphics.drawable.ColorDrawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager;
import android.widget.PopupWindow;

import com.cardbaobao.cardbabyclient.R;

/**
 * Created by Jiangzx on 2017/9/18 18:49.
 */

public class WebSharePop extends PopupWindow {
    public interface PopShareListener{
        int SHARE_WX=1;
        int SHARE_WX_CIRCLE=2;
        int SHARE_QQ=3;
        void onPlatClicked(int position);
    }

    private PopShareListener listener;

    public void setPopShareListener(PopShareListener listener){
        this.listener=listener;
    }

    public WebSharePop(Context context){
        View root= LayoutInflater.from(context).inflate(R.layout.pop_web_share,null);
        root.findViewById(R.id.view_click_dismiss).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
        root.findViewById(R.id.id_ll_weixin).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
                if(listener!=null){
                    listener.onPlatClicked(PopShareListener.SHARE_WX);
                }
            }
        });
        root.findViewById(R.id.id_ll_weixin_friends).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
                if(listener!=null){
                    listener.onPlatClicked(PopShareListener.SHARE_WX_CIRCLE);
                }
            }
        });
        root.findViewById(R.id.id_ll_qq_friends).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
                if(listener!=null){
                    listener.onPlatClicked(PopShareListener.SHARE_QQ);
                }
            }
        });
        setWidth(WindowManager.LayoutParams.MATCH_PARENT);
        setHeight(WindowManager.LayoutParams.MATCH_PARENT);
        setContentView(root);
        setAnimationStyle(R.style.CustomBottomAnimateStyle);
        setBackgroundDrawable(new ColorDrawable());
        setOutsideTouchable(false);
        setClippingEnabled(false);
    }
}
